import { StyleSheet } from 'react-native'
import React from 'react'
import { Button, View, ScrollView } from 'native-base'
import Cell from '../../components/Cell'
import { connect } from 'react-redux'
import { logoutAction } from '../../redux/actionCreator/user'
import UserCell from '../../components/UserCell'
import show from '../../axios/useCatch'

const Mine = ({ navigation, user, logoutAction }) => {
  const to = (name) => {
    console.log('+++++++++++++++++++++++++')
    navigation.navigate(name)
  }
  const logout = () => {
    logoutAction()
    navigation.replace('Login')
  }
  return (
    <ScrollView>
      <UserCell style={styles.user} data={user} link='UserInfo'></UserCell>
      <Cell leftText="我的物品" link="MyGoods"></Cell>
      <Cell leftText="上传商品" link="UploadGoods"></Cell>
      {/* <Cell leftText="我的空间" link="MyNews"></Cell> */}
      <Cell leftText="个人主页" link={{name: 'BusinessCenter', params: {userId: user._id}}}></Cell>
      {/* <Cell leftText="测试" link="Test"></Cell> */}
      
      {/* <Button onPress={() => to('Login')}>登录</Button> */}
      <Button style={{marginTop: 20}} colorScheme="secondary" onPress={logout}>退出登录</Button>
    </ScrollView>
  )
}

export default connect((state) => {
  return {
    user: state.userReducer
  }
},{
  logoutAction
})(Mine);

const styles = StyleSheet.create({
  user: {
    marginBottom: 10
  }
})